home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 February: Tool Chest / Dev.CD Feb 00 TC.toast / pc / what's new? / sample code / human interface toolbox / packagetool / sample package / htmlsample sources / ciconbuttons.h < prev    next >
Encoding:
C/C++ Source or Header  |  1999-12-02  |  3.7 KB  |  117 lines

  1. /*
  2.     file CIconButtons.h
  3.     
  4.     Description:
  5.     This file contains type declarations, constants, and routine prototypes
  6.     for accessing the routines implemented in CIconButtons.c.  These routines
  7.     are used to implement the color icon buttons displayed in the top of
  8.     HTMLSample's windows.
  9.     
  10.     HTMLSample is an application illustrating how to use the new
  11.     HTMLRenderingLib services found in Mac OS 9. HTMLRenderingLib
  12.     is Apple's light-weight HTML rendering engine capable of
  13.     displaying HTML files.
  14.  
  15.     Copyright: © 1999 by Apple Computer, Inc.
  16.     all rights reserved.
  17.     
  18.     Disclaimer:
  19.     You may incorporate this sample code into your applications without
  20.     restriction, though the sample code has been provided "AS IS" and the
  21.     responsibility for its operation is 100% yours.  However, what you are
  22.     not permitted to do is to redistribute the source as "DSC Sample Code"
  23.     after having made changes. If you're going to re-distribute the source,
  24.     we require that you make it clear in the source that the code was
  25.     descended from Apple Sample Code, but that you've made changes.
  26.     
  27.     Change History (most recent first):
  28.     10/16/99 created
  29. */
  30.  
  31. #ifndef __CICONBUTTONS__
  32. #define __CICONBUTTONS__
  33.  
  34. #include <Types.h>
  35.  
  36.     /* these are the resource types we use.  ResEdit
  37.     templates for these resource types are defined in
  38.     the application's resource fork. */
  39. enum {
  40.     kIconButtonIDListType = 'RBCL',
  41.     kIconButtonType = 'CICB'
  42. };
  43.  
  44.     /* buttons have three states, and three icons
  45.     for each of those states.  disabled is how it looks
  46.     when it cannot be clicked, up and down define
  47.     how it looks in each of those states. */
  48. enum {
  49.     kCBdisabled = 0,
  50.     kCBup = 1,
  51.     kCBdown = 2
  52. };
  53.  
  54. #pragma options align=mac68k
  55. typedef struct {
  56.     Rect bounds;
  57.     short drawnstate;
  58.     short cicnIDs[3]; /* resource id's for each state's cicn
  59.                 resource.  indexes in this array map to the
  60.                 states defined above. */
  61.     char stringdata[1]; /* variable size c string */
  62. } CIconButton, **CIconButtonHandle;
  63. #pragma options align=reset
  64.  
  65.  
  66. /* NewCIconButton retrieves a new color icon button
  67.     resource from the resource file.  the id number
  68.     corresponds to the resource id of the CICB resource. */
  69. CIconButtonHandle NewCIconButton(short id);
  70.  
  71.  
  72. /* DisposeCIconButton disposes of any structures allocated
  73.     for the color icon button allocated by NewCIconButton. */
  74. void DisposeCIconButton(CIconButtonHandle cicb);
  75.  
  76.  
  77. /* SetCIconButtonPosition sets the color icon button's 
  78.     screen postion. h and v are coordinates in the
  79.     current grafport. */
  80. void SetCIconButtonPosition(CIconButtonHandle cicb, short h, short v);
  81.  
  82.  
  83. /* GetCIconButtonStringData returns a new handled containing
  84.     the string data copied from the color icon resource.  The
  85.     handle will contain a C-style string terminated with a zero
  86.     byte.  It is the caller's responsibility to dispose of this
  87.     handle after it has been used. */
  88. OSErr GetCIconButtonStringData(CIconButtonHandle cicb, Handle *strdata);
  89.  
  90.  
  91. /* DrawCIconButton draws the icon button using the
  92.     as it should appear given the state specified.  state
  93.     should be either kCBdisabled, kCBup, or kCBdown.
  94.     The last state a button is drawn in affects the
  95.     result of TrackCIconButton. */
  96. void DrawCIconButton(CIconButtonHandle cicb, short state);
  97.  
  98.  
  99. /* TrackCIconButton should be called whenever a click is made
  100.     inside of a color icon button.  if the last time the button
  101.     was drawn its state was not kCBup or the click is outside
  102.     of the button, then this routine returns false. */
  103. Boolean TrackCIconButton(CIconButtonHandle cicb, Point where);
  104.  
  105. /* RBCLRsrcHandle defines the resource type used to store
  106.     a list of color icon button resource IDs.  In this example,
  107.     the user configurable button ids are stored in a RBCLRsrcHandle
  108.     resource. */
  109. #pragma options align=mac68k
  110. typedef struct {
  111.     short n;
  112.     short ids[1];
  113. } RBCLResource, **RBCLRsrcHandle;
  114. #pragma options align=reset
  115.  
  116. #endif
  117.